home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / NEWSOFT / AUGUST / ARCWEB / ReadMeDocs / Protocol < prev    next >
Text File  |  1997-03-19  |  37KB  |  774 lines

  1. /*
  2.  * ArcWeb
  3.  *
  4.  * Copyright (C) Stewart Brodie, 1994, 1995, 1996, 1997
  5.  *
  6.  * This product is supplied under the terms laid down in the `Terms' file.
  7.  *
  8.  * This file: Protocol
  9.  *
  10.  *   For ArcWeb versions 1.77 and later (until superceded)
  11.  *    Added flags for management of FTP directories (+object delete/rename)
  12.  *
  13.  *
  14.  *   Changes from protocol in version 1.17
  15.  *    Bits 6-13 in FetchRequest flags added - not all are implemented!
  16. ***    arcweb_TYPES_... macros withdrawn - use proper RISC OS types instead
  17.  *
  18.  *   Changes from protocol in version 0.35
  19.  *    Bit 5 in ..Request flags added to 
  20.  *
  21.  *   Changes from protocol in version 0.31
  22.  *      Bit 21 is reassigned in 'Done' messages for permanent relocation
  23.  *      which will enable ArcWeb to modify hotlist entries etc. when the
  24.  *      server has sent a 301 response.
  25.  *      Some bit descriptions corrected.  The table was correct, but sometimes
  26.  *      the descriptions had not been.
  27.  *
  28.  *   Changes from protocol in version 0.28
  29.  *      Message_ArcwebWebBrowser added to allow a non-ArcWeb browser to
  30.  *    transmit its name and version to ArcWeb.  OTHER BROWSERS MUST USE THIS
  31.  *    Notes on this message added
  32.  *
  33.  *   Changes from protocol in version 0.26
  34.  *      'reload' and 'fast images' bits have been switched
  35.  *      the ExternalLaunch can accept non-extended URLs, although such use is
  36.  *      deprecated.
  37.  *
  38.  *   Changes from protocol in version 0.25
  39.  *      Message_ArcwebExternalLaunch added
  40.  *      Message_ArcwebConfigure added
  41.  *      Notes on both of the above added.
  42.  *
  43.  *   Changes from protocol in version 0.20
  44.  *      More flags added to FetchRequest & PostRequest messages.  These are
  45.  *      for the information of the fetcher only and do not need to be preserved
  46. ***     From version 0.25, the use on non-extended URLs is deprecated
  47.  *
  48.  *   Changes from protocol in version 0.19
  49.  *      Comments about bit 27 handling (arcweb_FLAGS_url_changed) changed
  50.  *      Comments in several other sections changed
  51.  *      Whole document should be reread by those implementing any part of
  52.  *      any of the ArcWeb protocols
  53.  *
  54.  *   Changes from protocol in version 0.12
  55.  *      Extensions to the Message_ArcwebRenderDone buffer.  The image renderer
  56.  *      must insert the X and Y pixel size of a graphical image (to enable
  57.  *      ArcWeb to calculate URLs for imagemaps unless the information is not
  58.  *      available or not applicable (eg. for sound)
  59.  *
  60.  *
  61.  *   Changes from protocol in version 0.11
  62.  *      Extended URL protocol defined
  63.  *      - in *Request message blocks
  64.  *      - notes about ownership of file handles
  65.  *      - in comments about the Flags word
  66.  *      - comments about how to handle Location: header from HTTP servers
  67.  *      Message_ArcwebEMailRequest/Done added
  68.  *      Handling of bit 27 in non-extended URL messages
  69.  *      In Other Notes: comment about expiry dates updated
  70.  *      Warning about setting type bits in Done messages
  71.  *      Renderer protocol warnings added
  72.  *      Sender protocol renamed to Poster protocol
  73.  *      EMail protocol added (uses a new bit in flags)
  74.  *      Suggestion about intelligent HTTP fetchers prefetching images
  75.  *      Message_ArcwebAbortRequest added   + description
  76.  *      Message_ArcwebTransferStatus added + description
  77.  *
  78.  */
  79.  
  80. This file describes the protocols used by ArcWeb.  There are nine protocols
  81. planned, although only the first eight are fully implemented so far.
  82.  
  83.  
  84.   * Fetcher Protocol
  85.   * Renderer Protocol
  86.   * Quit Protocol
  87.   * Extended URL Protocol
  88.   * Poster Protocol
  89.   * Email Protocol
  90.   * External Launch Protocol
  91.   * Configuration Protocol
  92.   * Expire Protocol
  93.  
  94.  
  95. Programmers supporting these protocols must be extremely careful with their
  96. memory, message and protocol management.  The protocols are allowed to be
  97. concurrent and nested.
  98.  
  99. The obvious example is that a renderer may find an inline image in a
  100. document, and will hence want to issue a request to fetch it.  A not so
  101. obvious example is an intelligent HTTP fetcher which tries to intelligently
  102. scan the returned document (if it was HTML) to pick out <img> tags and kick
  103. off requests for these in-lined images so that when ArcWeb comes to ask for
  104. them, a swifter reply can be made.  The impact of such a system would be
  105. more noticable, the more images there are inlined in a document.
  106.  
  107.  
  108. General
  109. =======
  110.  
  111.   Each protocol consists of 2 messages, a "Request" and a "Done". The
  112. Request is sent with event code 18 to force an acknowledgement.  The
  113. fetcher/renderer should acknowledge with the Done message to prevent the
  114. Wimp returning the message to the originator.  Should the fetcher/renderer
  115. wish to call Wimp_Poll before it is ready to send the Done reply, it MUST ack
  116. the message (ie. fill in the ref fields and reply with event type 19 to
  117. prevent the Wimp returning it to the originator), and then send the Done
  118. message when it is ready (having remembered to fill in the your_ref field
  119. from the my_ref of the original Request).
  120.  
  121.   Instead of sending a Wimp acknowledgement with event type 19 to prevent
  122. delivery failure, as mentioned above, it would be much better to actually
  123. reply with a Message_ArcwebTransferStatus, which doubles both as the ack and
  124. as a useful message.  Further Message_ArcwebTransferStatus messages can be
  125. sent periodically (use event type 17 and zero the ref field for these)
  126.  
  127.   C programmers must use requester.h to define the structures used. 
  128. The types have been divorced from any Wimp library, only char, void and int
  129. types have been used.
  130.  
  131.  
  132. Messages
  133. ========
  134.  
  135. buf is the buffer returned from Wimp_Poll (&e->data in Risc_OSlib).  The
  136. obvious fields have been omitted (ie. buf+0 to buf+12).
  137. The 'Private ArcWeb handle' must always be preserved, as this is the only
  138. way ArcWeb can deliver replies to the request originator.
  139.  
  140. The types of each entry are given:  str0 = zero terminated string.  strN = 
  141. string whose length is defined elsewhere.  str0/N = string zero terminated
  142. unless it is maximum length (defined elsewhere) in which case the terminator
  143. is missing; date5 = 5 byte date string (in UTC) as returned by OS_Word 14,3
  144.  
  145. The buffers are all defined together and then explained below.  requester.h
  146. contains C structures for these messages.
  147.  
  148.  
  149.  
  150.  
  151. Message_ArcwebFetchRequest      (msg_Arcweb__base +  0)
  152.  
  153.         buf+16  int     Message_ArcwebFetchRequest      (0x4A240)
  154.         buf+20  void*   Private ArcWeb handle
  155.         buf+24  int     Flags
  156.         buf+28  int     RISC OS file handle (source)
  157.  
  158. EITHER  buf+32  str0    Uniform Resource Locator (fully qualified)
  159.  
  160.     OR  buf+32  int     RISC OS file handle (URL) (if flags bit 22 set)
  161.  
  162.  
  163. Message_ArcwebFetchDone         (msg_Arcweb__base +  1)
  164.  
  165.         buf+12  int     my_ref from Message_ArcwebFetchRequest
  166.         buf+16  int     Message_ArcwebFetchDone         (0x4A241)
  167.         buf+20  void*   Private ArcWeb handle
  168.         buf+24  int     Flags
  169.  
  170.  EITHER buf+28  str0    Error message
  171.  
  172.      OR buf+28  int     Zero=this item has an expiry date
  173.         buf+32  int     Non-zero=use default expiry delay
  174.         buf+36  date5   Expiry date in UTC (if buf+32 zero, and buf+28 zero)
  175.  
  176.  
  177. Message_ArcwebRenderRequest     (msg_Arcweb__base +  2)
  178.  
  179.         buf+16  int     Message_ArcwebRenderRequest     (0x4A242)
  180.         buf+20  void*   Private ArcWeb handle
  181.         buf+24  int     flags
  182.         buf+28  int     RISC OS file handle (source)
  183.         buf+32  int     RISC OS file handle (temporary)
  184.         buf+36  int     RISC OS file handle (diagram)
  185.         buf+40  int     RISC OS file handle (link)
  186.         buf+44  int     size of data following
  187.         buf+48  ---     (contents of buf+44) bytes of source file
  188.  
  189. Message_ArcwebRenderDone        (msg_Arcweb__base +  3)
  190.  
  191.         buf+16  int     Message_ArcwebRenderDone        (0x4A243)
  192.         buf+20  void*   Private ArcWeb handle
  193.         buf+24  int     flags
  194.  
  195. EITHER  buf+28  int     size of image in x pixels (0 if N/A)
  196.         buf+32  int     size of image in y pixesl (0 if N/A)
  197.  
  198. OR      buf+28  str0    error message
  199.  
  200.  
  201. Message_ArcwebPostRequest       (msg_Arcweb__base +  4)
  202.  
  203.         buf+16  int     Message_ArcwebPostRequest       (0x4A244)
  204.         buf+20  void*   Private ArcWeb handle
  205.         buf+24  int     flags
  206.         buf+28  int     RISC OS file handle (source)
  207.         buf+32  int     RISC OS file handle (form)
  208.  
  209. EITHER  buf+36  str0    Uniform Resource Locator (if flags bit 22 clear)
  210.  
  211.     OR  buf+36  int     RISC OS file handle (URL) (if flags bit 22 set)
  212.  
  213. Message_ArcwebPostDone          (msg_Arcweb__base +  5)
  214.  
  215.         buf+12  int     my_ref from Message_ArcwebPostRequest
  216.         buf+16  int     Message_ArcwebPostDone          (0x4A245)
  217.         buf+20  void*   Private ArcWeb handle
  218.         buf+24  int     flags
  219.  
  220.  EITHER buf+28  str0    Error message
  221.  
  222.      OR buf+28  int     Zero=this item has an expiry date
  223.         buf+32  int     Non-zero=use default expiry delay
  224.         buf+36  date5   Expiry date in UTC (if buf+32 zero, and buf+28 zero)
  225.  
  226. Message_ArcwebEMailRequest      (msg_Arcweb__base +  6)
  227.  
  228.         buf+16  int     Message_ArcwebEMailRequest      (0x4A246)
  229.         buf+20  void*   Private ArcWeb handle
  230.         buf+24  int     flags
  231.         buf+28  int     RISC OS file handle (form file containing e-mail)
  232.  
  233. Message_ArcwebEMailDone         (msg_Arcweb__base +  7)
  234.  
  235.         buf+12  int     my_ref from Message_ArcwebEMailRequest
  236.         buf+16  int     Message_ArcwebEMailDone         (0x4A247)
  237.         buf+20  void*   Private ArcWeb handle
  238.         buf+24  int     flags
  239.  
  240.  
  241. Message_ArcwebQuit              (msg_Arcweb__base + 32)
  242.  
  243.         buf+16  int     Message_ArcwebQuit              (0x4A260)
  244.  
  245.  
  246. Message_ArcwebExpire            (msg_Arcweb__base + 33)
  247.  
  248.         buf+16  int     Message_ArcwebExpire            (0x4A261)
  249.         buf+20  void*   Private ArcWeb handle
  250.         buf+24  int     flags
  251.         buf+28  int     RISC OS file handle (source)
  252.  
  253. Message_ArcwebAbortRequest      (msg_Arcweb__base + 34)
  254.  
  255.         buf+16  int     Message_ArcwebAbortRequest      (0x4A262)
  256.         buf+20  void*   Private ArcWeb handle
  257.         buf+24  int     reserved
  258.         buf+28  str0    reason for abort (could log this)
  259.  
  260. Message_ArcwebTransferStatus    (msg_Arcweb__base + 35)
  261.  
  262.         buf+16  int     Message_ArcwebTransferStatus    (0x4A263)
  263.         buf+20  void*   Private ArcWeb handle from ..Request
  264.         buf+24  int     reserved, must be zero
  265.         buf+28  int     status flags
  266.         buf+32  int     total size of data to be transmitted
  267.         buf+36  int     size of data transmitted so far
  268.         buf+40  int     total size of data to be received (if known)
  269.         buf+44  int     size of data received so far
  270.         buf+48  str0    current status of communication
  271.  
  272. Message_ArcwebConfigure         (msg_Arcweb__base + 36)
  273.  
  274.         buf+16  int     Message_ArcwebConfigure         (0x4A264)
  275.         buf+20  void*   Unused
  276.         buf+24  int     Unused
  277.         buf+28  str0    Application to be configured
  278.         
  279. Message_ArcwebExternalLaunch    (msg_Arcweb__base + 37)
  280.  
  281.         buf+16  int     Message_ArcwebExternalLaunch    (0x4A265)
  282.         buf+20  void*   Sender's private handle (not ArcWeb's)
  283.         buf+24  int     Flags (see notes on this Message)
  284.         buf+28  int     RISC OS file handle (URL)
  285.  
  286. Message_ArcwebLaunchDone        (msg_Arcweb__base + 38)
  287.  
  288.         buf+12  int     my_ref from Message_ArcwebExternalLaunch
  289.         buf+16  int     Message_ArcwebLaunchDone        (0x4A265
  290.         buf+20  void*   Preserved from the Launch message
  291.         buf+24  int     Flags (will have bit 31 set on an error)
  292.         buf+28  str0    Error message
  293.  
  294.  
  295. Ownership of File Handles
  296. =========================
  297.  
  298. Some people have expressed concern at the apparent capability to lose track
  299. of which task 'owns' the RISC OS file handles passed in the messages.  There
  300. is never any ambiguity, and this section will clarify this.
  301.  
  302. The task which sends the FetchRequest/RenderRequest/PostRequest message will
  303. have called OS_Find to open the file, and this task (normally ArcWeb itself)
  304. owns the returned file handle UNTIL it calls Wimp_Poll.  At this point, the
  305. Wimp will start delivering the Request message to each task in turn.  While
  306. the Wimp is doing this the file handle is in limbo (in effect, it is
  307. 'lost').
  308.  
  309. There are two possible continuations:
  310.  
  311. i) As soon as a task receives the Request message and decides that it wishes
  312. to reply to the Request message, it will either send the corresponding Done
  313. message, OR just ack it with the intention on replying properly later.  It
  314. is upon the sending of this Done message, or Ack, (the call to
  315. Wimp_SendMessage) that the task becomes the owner of the file handle, and
  316. hence responsible for closing the file handle when it is finished with.
  317.  
  318. ii) The other scenario is when *no* task wants to reply to the Request
  319. message. In this case, the Wimp will deliver an event code 19 copy of the
  320. message to the originator.  The originator now regains ownership of the file
  321. handle and is responsible for it (ArcWeb closes the file(s) and generates
  322. an error if this is sensible).
  323.  
  324. In general, for any task, if it receives a Request message, it is guaranteed
  325. to have exclusive use of the file handle until it next calls Wimp_Poll.
  326.  
  327. This system ensures that ownership of the file is guaranteed to be allocated
  328. to one particular task in the system at any time, and that a task has to
  329. 'claim' ownership explicitly, as shown in (i) above.
  330.  
  331.  
  332.  
  333. Flags
  334. =====
  335.  
  336. The Flags word contains several useful bits of information:
  337.  
  338.    On ..Request messages:
  339.    
  340.     bit  0        Reserved - must be zero (was reload bit in old versions)
  341.         bit  1          If set, the previous page was a local: URL
  342.         bit  2          If set, fast images are being used - not implemented
  343.         bit  3          If set, the POST request should be sent as a PUT
  344.         bit  4          If set, the user has disabled image fetching
  345.     bit  5        If set, browser allow InProgress response for THIS fetch
  346.     bit  6        Reserved - must be zero
  347.     bit  7        Internal use only - must be zero for non-ArcWeb tasks
  348.     bit  8        If set, user has forced image fetching for this fetch
  349.     bit  9        If set, user requested a PUT operation
  350.     bit  10        If set, user requested the URI be created as a directory
  351.     bit  11        If set, user requested the directory URI be deleted
  352.     bit  12        If set, user requested deletion of URI
  353.     bit  13        If set, user requested rename of URI
  354.     bit  21        If set, the email message is already complete
  355.    
  356.    On ..Done messages
  357.    
  358.         bits 0-15       RISC OS file type/ArcWeb file type (see bits 16,30)
  359.         bit  16         If set, bits 0-15 are ArcWeb file type, else RISC OS
  360.         bit  21        If set (+bit 27 set), new URL is permanent (301 Moved)
  361.  
  362.    In both types of message:
  363.  
  364.         bits 17 and 18  Reserved (must preserve in replies)
  365.         bit  19         If set, user requested a 'save to disc'
  366.        bit  20        If set, user requested a reload on this document
  367.         bit  21         If set, the email message is already complete
  368.         bit  22         If set, an extended URL is in use
  369.         bit  23         If set, ArcWeb will not display the results of the render
  370.         bit  24         If set (+bit 31 set), ArcWeb will not raise an error
  371.         bit  25         If set, this request is for an inlined resource
  372.         bit  26         If set, ArcWeb will close the window which issued request
  373.         bit  27         If set, extended URL has changed
  374.         bit  28         If set, symbolic link request/confirm
  375.         bit  29         If set, ArcWeb will not attempt to render the file
  376.         bit  30         If set, bits 0-16 are valid, else they are invalid
  377.         bit  31         If set, buffer contains an error message
  378.  
  379. The error bit (31) determines which of the options in two of the messages
  380. above, is in force.  If the error bit is set, ArcWeb will raise an error to
  381. the user UNLESS bit 24 is also set (indicating that the other application
  382. has already handled this - this is the preferred way of doing it).
  383.  
  384. When a request to fetch a new page is issued, ArcWeb remembers which window
  385. (if any) launched the request.  Once a successful RenderDone has been
  386. delivered to the window, it will self-destruct if bit 26 is set.  ArcWeb
  387. will set this bit itself according to the user's choice, and so this bit
  388. should always be preserved, unless you absolutely want to set it (see bit 23
  389. below).  That window is not allowed to launch further requests until the
  390. whole transaction is completed.  This blocked state is indicated to the user
  391. by the web animation in the information window for a busy page.
  392.  
  393. If you find that bit 22 is set upon receipt of a Request involving a URL,
  394. then the buffer will not contain a URL, but a file handle of a file that
  395. does.  The file will have been opened in R/W mode with OS_Find.  You should
  396. read the whole of the file to obtain the URL.  It may be terminated by a
  397. whitespace character, or by EOF.  The same rules about responsibility for
  398. closing the file apply as for the other handles in ..Request messages.
  399.  
  400. If, during a conversation with an HTTP server, you receive a Location:
  401. directive indicating a document relocation, then you should amend the
  402. contents of the extended URL file to represent the new target URL.  You must
  403. set flag bit 27 in the Done message (which you don't send immediately - you
  404. pretend as though you had received the new URL from the Request message). 
  405. The transparent obedience to Location: directives is not strictly required
  406. (and the change cannot be signalled to ArcWeb if the extended URL protocol
  407. is not being used), but is MOST HIGHLY ENCOURAGED.  At some point in the
  408. future, only extended URLs will be used at all.  If the response from the
  409. server was a 301 'moved permanently', then you should also set bit 21 in
  410. the ..Done message to inform ArcWeb.  ArcWeb will then scan the hotlist
  411. and history for that URL and change them, as HTTP spec suggests.
  412.  
  413. *** From version 0.25, the use on non-extended URLs is deprecated
  414.  
  415. If bit 19 was set, then the user did a SHIFT-click on the link to force it
  416. to be loaded to disc only.
  417.  
  418. If bit 23 is set in RenderDone, ArcWeb will not display the results of the
  419. render.  This is to allow applications such as image renderers to open their
  420. own window to display the picture.  This must NOT be done if bit 25 is set
  421. (as someone else is trying to render an inline image).  If bit 25 is set,
  422. the application must convert the image into a sprite file and store it in
  423. the 'diagram' file.  If you set bit 23, it is a good idea to clear bit 26 in
  424. order not to confuse the user.  Make sure that you set the size of the image
  425. in pixels (if appropriate) in the RenderDone message, as this will enable
  426. image maps to work correctly.
  427.  
  428. Upon receipt of a FetchRequest message, the application should check bit 28. 
  429. If bit 28 is set, then the application may opt to retrieve the file to its
  430. own private directory and store the name of the file in the 'source' file. 
  431. If it declines to do this (or bit 28 is clear anyway), bit 28 should be
  432. cleared on the response and the fetched file placed in 'source'.  This
  433. facility is provided mainly for the benefit of ArcWebLcl to avoid copying
  434. files around the locally available filesystems.
  435.  
  436. If bit 21 is set on receipt of a EMailRequest message, then this indicates
  437. that the form file contains a complete e-mail message ready to be mailed
  438. off (excluding From: header).  If bit 21 is clear, then this indicates that
  439. the helper application needs to open some kind of editor to allow the user
  440. to complete the e-mail.  The editor should be initialised with the contents
  441. of the form file.  If it is going to do anything at all, then the helper
  442. application must reply with a EMailDone message.
  443.  
  444. Bit 4 is used by ArcWeb to indicate to fetchers that the user has
  445. specifically requested that images are not fetched and rendered.  This
  446. allows 'intelligent' HTTP fetchers mentioned at the start of this document,
  447. to parse the HTML responses to its fetches and immediately kick off the
  448. transfers for these images before the render of the document begins.  If bit
  449. 4 is set, then the fetcher should not do this.
  450.  
  451. Bits 10-13 are relevant only for Message_ArcwebFetchRequest messages.  They
  452. indicate that the operation is targeted at direct manipulation of the URL.
  453. These are not yet fully implemented (MKDIR and RMDIR are implemented for FTP
  454. only)  The two directory ops require a terminating / on the URL.  Bits 10-13
  455. are to be treated as a 4-bit unsigned value rather than a bit-field, and so
  456. it MUST be treated as such by applications.
  457.  
  458. If bit 10 is set (directory creation), then an attempt to create the
  459. directory is made and upon a successful response, it is treated as if a
  460. redirection had occurred to the same resource (so the directory you just
  461. created is opened).  However, if bit 11 is ALSO set, this redirection does
  462. NOT occur.  ie. a value of 1 means create directory and enter it; a value
  463. of 3 means create directory but do not enter it; a value of 2 means
  464. delete directory.  A value of 4 means delete the object, and a value of 8
  465. means rename the object.
  466.  
  467.  
  468.  
  469.  
  470. Message_ArcwebAbortRequest
  471. ==========================
  472.  
  473. Upon receipt of this message, the fetcher application retrieving a URL under
  474. the given ArcWeb Private handle, should terminate the fetch with an error. 
  475. It should acknowledge this message with Message_ArcwebFetchDone, after
  476. setting the flags correctly indicating some kind of error.  All active
  477. fetches associated with the handle should be stopped.  This allows
  478. intelligent fetchers to stop any automatic fetches that they might have
  479. issued, to fetch inlined images.
  480.  
  481. At the choice of the FETCHER, it may decide to ignore the AbortRequest and
  482. continue fetching data.  The most obvious situation in which this is useful
  483. is if the fetch is large and nearly complete anyway - say less than 1 second
  484. estimated to completion.  You must acknowledge the AbortRequest with a
  485. FetchDone, in the usual manner (ie. you can acknowledge the message first,
  486. then send a reply later).  The amount of time may be configurable in the
  487. fetcher, but should not exceed a few seconds as this may confuse the user.
  488.  
  489.  
  490.  
  491. Message_ArcwebTransferStatus
  492. ============================
  493.  
  494. A fetcher which wishes to inform the user of the status of the communication
  495. between itself and the remote information server (FTP, HTTP, Gopher, etc..)
  496. may use this message to inform the browser of its progress.  The 4 size
  497. elements in the message may be used by the browser to create a graphical
  498. representation of the communication status.  Values of -1 should be known
  499. for unknown quantities (0 is reserved for indicating no bytes yet
  500. transferred or expected).  The browser may choose to ignore these values and
  501. rely on the description string, which should say something like:
  502.  
  503. 1000 bytes out of 2000 byte document read
  504. 0 bytes out of 16384 bytes of inlined image read
  505. Looking up louis.ecs.soton.ac.uk ...
  506.  
  507. or whatever it feels is appropriate.  Fetcher writers must recognise that
  508. the browser may attempt to display these messages in an icon, and will hence
  509. be issuing redraw requests (even if only via Wimp_SetIconState) for each
  510. message received.  The fetcher should provide a facility for disabling these
  511. messages, and not send them too frequently - two or three times per second
  512. is quite enough.
  513.  
  514.  
  515. If you are going to provide byte counts as in the examples above, I HIGHLY
  516. RECOMMEND using OS_Convert(Fixed)FileSize to give a useful display.  It
  517. isn't terribly useful to know that 65539 bytes out of 268435456 bytes have
  518. been received.  Far better, even if slightly inaccurate, to say '64K out of
  519. 256M' and maybe show the percentage that represents.
  520.  
  521. Returned messages should typically be less than about 64 characters long.
  522.  
  523. The browser may ignore these messages, and so the fetcher should not send
  524. them recorded delivery (Wimp event type 18).
  525.  
  526. The flags for Message_ArcwebTransferStatus:
  527.  
  528.         bit   0         If set, transmission is in progress
  529.         bit   1         If set, reception is in progress
  530.         bit   2         If set, transmission is complete
  531.         bit   3         If set, reception is complete
  532.         bit   4         If set, other comms. are in progress eg. DNS lookup
  533.         bits  5 - 31    Reserved
  534.  
  535.  
  536.  
  537. Other Notes
  538. ===========
  539.  
  540. You must preserve the ArcWeb Private Handle.  This is a private pointer to a
  541. part of ArcWeb's application memory used to distribute the replies which
  542. ArcWeb receives.
  543.  
  544. When specifying an expiry date in FetchDone messages, if you intend to
  545. specify a date rather than allow the default to be used, then you must
  546. specify this as an exact date.  ie. not relative to the current time, you
  547. must add it up yourself.  HTTP servers may supply expiry dates on documents
  548. which they return.  These should be honoured (see documentation of the
  549. Territory module's handling of Time & Date).
  550.  
  551. The 'source', 'temporary', 'diagram' and 'link' words in the FetchRequest
  552. and RenderRequest messages are RISC OS file handles to the appropriate files
  553. in ArcWeb's cache.  If you acknowledge either of the Request messages, YOU
  554. are responsible for closing the files (ie. passing the handle to OS_Find 0).
  555. You must close ALL the file handles in the message even if you don't use
  556. them all.  The reason for passing handles around is that filenames  won't
  557. necessarily fit in the message buffer (particularly when you want to pass 5
  558. of them).  If just having the handle is inconvenient, you should use OS_Args
  559. 7 to convert the handle into a filename (as !ArcWebLcl does), close the file
  560. and reopen it how you want to do it.  BUT BEWARE: only do this if you are
  561. going to acknowledge the message (otherwise other recipients of the message
  562. will find that they have an illegal file handle in the message).  For
  563. FetchRequest, 'source' is opened as read/write (OS_Find 0x83 - [I always
  564. thought that was for output only, but my RO3 PRMs say otherwise]).  For
  565. RenderRequest, 'source' is opened read only (OS_Find 0x43), and the others
  566. are read/write (OS_Find 0x83).  For PostRequests, the source is as for
  567. FetchRequests, and the form file is read only.  For EMailRequests, the form
  568. file is read-only.
  569.  
  570. [An example of using OS_Args 7 in BASIC is in !ArcWebLcl which uses OS_CLI
  571. to issue a straight *COPY command when the symlink bit is clear]
  572.  
  573.  
  574. You do not need to fill in the file type bits (0-15,16 and 30) when sending
  575. the Fetch Done message, but it will assist the renderers in deciding what to
  576. do with the document if you do.  The most common types returned are plain
  577. text (&FFF), HTML (&FAF), GIF (&695), JPEG (&C85) and XBM (&10104).
  578.  
  579. WARNING: Most HTTP servers are configured with a default type to return in
  580. the case that it cannot work out the type of a file from its name or a
  581. specific directive telling it the file type.  This default type is usually
  582. text/plain.  This is a problem when you wish to store binary files (eg.
  583. arcweb.arc) on HTTP servers, as louis.ecs.soton.ac.uk's server will tell you
  584. that this is a text/plain file, when obviously it isn't.  ArcWeb 0.12 and
  585. later will examine the data in the RenderRequest message* to ensure that it
  586. does not contain non-printable characters before attempting to render it.
  587.  
  588. * see renderer protocol discussion below
  589.  
  590.  
  591. Renderer Protocol
  592. =================
  593.  
  594.   The Renderer Protocol is used to transform a file into something which can
  595. be viewed in the ArcWeb window.  ArcWeb generates a DrawFile (type &AFF)
  596. to represent the HTML document.  I have written my own parser to read the
  597. HTML file (conforms with the HTML 2.0 specification, 13 June 1994) and
  598. display it.  Renderers should convert images into sprites and store them in
  599. the 'diagram' file (but only if it is an inline data fetch - see discussion
  600. of bits 23 and 25 above).  ArcWeb will be expecting a sprite file to be
  601. there which it can then import.  It will take the first sprite out of the
  602. file.  ArcWeb will handle RISC OS sprite files (&FF9) itself (although it
  603. will broadcast the message with the expectation of receiving it back).  You
  604. should not acknowledge render requests for files of type &FF9
  605.  
  606.   Renderers should inspect the file type bits in the RenderRequest to see
  607. whether the file is of a type which they can handle.  If the type is not
  608. known* (bit 30 is clear), then the renderer may inspect the first few bytes
  609. of the file.  Before sending the RenderRequest message, ArcWeb will have
  610. loaded in as much of the file as possible to the message (to fill it up to
  611. 256 bytes).  The amount of data in the message is in buf+44, and the data
  612. starts at buf+48.  Thus up to 208 bytes of data will be present (currently
  613. it is 208 unless the file is not that long, in which case the whole file is
  614. there).  If 208 bytes is not enough, the renderer may use the file handle
  615. given in the message to read more of the file in.  The file pointer should
  616. be reset to zero if it decides that it can't handle it.  As a safeguard,
  617. Renderers MUST NOT assume that the file pointer will be zero, and should set
  618. it explicitly.
  619.  
  620. * The renderer may decide that it doesn't 'trust' the given file type.  If
  621. that is the case, then it is allowed to ignore bit 30 and attempt to
  622. recognise the file type from the data in the message buffer and act on that
  623. alone.
  624.  
  625.  
  626.  
  627. Quit Protocol
  628. =============
  629.  
  630.   Fetchers and Renderers should have a configurable option to allow them to
  631. quit when ArcWeb dies.  This provides a clean way of shutting ArcWeb and all
  632. its related programs down in one go.  Upon receipt of a Message_ArcwebQuit
  633. message, store the task handle (in buf+4) and wait for the Wimp task
  634. closedown message (Message_TaskCloseDown 0x400C3) to arrive with the given
  635. task handle.  [To prevent ArcWeb closing down, acknowledge the
  636. Message_ArcwebQuit message - not in version 0.08.  ArcWeb will exit anyway.]
  637.  
  638.   By using an extra message, this avoids the need for the auxiliary apps to
  639. lookup the task name from the handle to check whether it was ArcWeb or not,
  640. and this also guards against the task name changing.
  641.  
  642.   Do not acknowledge Message_ArcwebQuit unless you wish to prevent the
  643. shutdown (treat it like you would treat Message_PreQuit)
  644.  
  645.  
  646. Expire Protocol
  647. ===============
  648.  
  649.   If a fetcher has used a symbolic link when fetching a file then that file
  650. should be expired upon receipt of Message_ArcwebExpire.  ArcWeb will pass you
  651. a handle to the file in the cache.  If the symbolic link bit (bit 28) is set
  652. in the flags, then the file to be removed is really the file whose name is
  653. in the file whose handle you have been given.  !ArcwebLcl ignores this
  654. message completely (as it should).  This protocol is not fixed and should
  655. not yet be used (there is a particular problem with extended URLs), but
  656. fetcher authors should be aware of its future existence.  ArcWeb does not
  657. currently send Message_ArcwebExpire messages.
  658.  
  659.  
  660. Poster Protocol
  661. ===============
  662.  
  663. This protocol will be used when ArcWeb wants to send information to a URL
  664. rather than retrieve it, ie. when an HTML form with a method of POST has
  665. been completed and the SUBMIT button has been pressed.  If the form did not
  666. override the default (GET) or chooses the GET method, the the FetchRequest
  667. protocol is used, and the fetcher is not aware of the fact that the data
  668. transfer has happened (an extended URL will have been used).
  669.  
  670. PostRequest should be treated exactly like Message_ArcwebFetchRequest,
  671. except that the 'form' file handle is a RISC OS file handle pointing to a
  672. read-only file containing data to tag onto the end of the request. 
  673. Some forms use the PUT method instead.  The fetcher can determine whether
  674. the submission was a post or put by checking arcweb_FLAGS_post_was_put bit
  675. and sending a PUT instead of a POST if it was set.
  676. Obviously, the fetcher should issue a POST command to the HTTP server
  677. instead of a GET.  The data in the form file will be suitable for tacking on
  678. IMMEDIATELY after the POST and other usual headers, as it will contain a
  679. Content-Length: header followed by a blank line, followed by the form data
  680. with all the appropriate escape characters already substituted in.  This
  681. data should be passed transparently to the HTTP server.  The fetcher should
  682. respond to ArcWeb with a Message_ArcwebPostDone in exactly the same format
  683. as a response to Message_ArcwebFetchRequest.  The buffer for PostDone is the
  684. same as the buffer for FetchDone.  This is because the target script on the
  685. server responds with a new virtual document, usually confirming that the
  686. data entry was successful/failed etc.
  687.  
  688. EMail Protocol
  689. ==============
  690.  
  691. This protocol will be used when ArcWeb wants to send some e-mail.  ArcWeb
  692. will send this message when the users attempts to follow a mailto: hypertext
  693. link, or when a form with a mailto: method is submitted.  In the former
  694. case, the message remains to be constructed, so the contents of the form
  695. file should be taken as the initial text to be placed in the editor.  ArcWeb
  696. guarantees to make the first line of the file the To: header.  Furthermore,
  697. bit 21 will be clear indicating that the message is not yet complete.  In
  698. the latter case (the invoked form), bit 21 will be set, indicating a
  699. complete message is in the buffer and ready for mailing.  ArcWeb will still
  700. guarantee that the first line in the form file is the To: header, but will
  701. also add an X-Mailer: header, a Date: header and any other headers as
  702. directed by MH tags in the form (eg. Subject: headers)
  703.  
  704. Upon receipt of the EMailRequest, the e-mail application should take over
  705. the process of sending e-mail and return an EMailDone, after taking a copy
  706. of the form file contents and closing the form file.  ArcWeb is not
  707. concerned with what happens to the e-mail next, as far as it is concerned,
  708. the email is sent.
  709.  
  710. There is no virtual document returned from an EMailRequest.  The e-mail
  711. application may flag an error in the usual way (and choose whether to report
  712. the error itself of not).  ArcWeb will open a dialogue box indicating the
  713. status of the e-mail, rather than generating a complete new page.
  714.  
  715. ArcWebTCP will provide the email facility only if it is configured to do so.
  716. To configure it, you must give it your email address and SMTP gateway name.
  717.  
  718.  
  719. Configuration Protocol
  720. ======================
  721.  
  722. This protocol is used when the user invokes an option off the Configure menu
  723. on ArcWeb's icon bar menu.  It allows the configuration windows of the
  724. helper applications to be accessed even when no icon bar icon is installed.
  725. The name of the application (case insensitive) will be in the message.
  726. The name may also be a string of length 1, that character being * which
  727. indicates that all applications are to open their configuration windows.
  728. There is no acknowledgement required for this protocol.
  729.  
  730.  
  731. External Launch Protocol
  732. ========================
  733.  
  734. This protocol is used when an external application, such as a mail reader,
  735. wishes to launch a URL fetch.  The 'Private handle' field will be
  736. preserved in any response from ArcWeb allowing the client to have
  737. multiple outstanding requests, although ArcWeb does not guarantee to be
  738. able to support multiple concurrent external requests at this time. The flags
  739. field corresponds to the usual flags specified for ..Request messages with
  740. the following exceptions:  It should have bit 22 set indicating that a file
  741. handle is present which contains a fully qualified URL.  It should have no
  742. other flags may be set except for arcweb_FLAGS_reload,
  743. arcweb_FLAGS_load_to_disc, or arcweb_FLAGS_images_disabled
  744.  
  745. This message should be sent recorded delivery (ie. Wimp event type 18) and
  746. upon receipt of a failure (Wimp returns a Wimp event type 19) the external
  747. application must close the URL file and issue its own error.  It must
  748. assume that ArcWeb was not loaded or was otherwise unable to respond. 
  749. ArcWeb will respond with a Message_ArcwebLaunchDone message if it can (and
  750. thus assume full responsibility for the URL file handle).  The error status
  751. is indicated by the error bit in the flags, and if this is set, then the
  752. buffer contains an error message, otherwise the buffer contents are
  753. indeterminate.
  754.  
  755.  
  756. Message_ArcwebWebBrowser
  757. ========================
  758.  
  759. ArcWebTCP sends browser identification to HTTP servers when it talks to them. 
  760. By default, it sends the latest known version of ArcWeb when it was compiled. 
  761. However, since other web browsers can use the facilities provided by
  762. ArcWebTCP, I have added this message to allow the browser to identify itself
  763. to remote servers.  The content of the buffer (see requester.h) is a control
  764. character terminated string of the form String/0.00 where String is the
  765. browser name (may contain spaces) and 0.00 is the version number.  ArcWebTCP
  766. will insert this string into the headers and append string " (Acorn RISC OS;
  767. ARM) ArcWebTCP/v.vv" to it, substituing its version number.  Any control
  768. characters or top bit set characters are treated as terminators to prevent
  769. any security breaches.
  770.  
  771.  
  772.  
  773. ==END==
  774.